<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>FabGL: VGA/NetworkTerminal/NetworkTerminal.ino</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">FabGL
   </div>
   <div id="projectbrief">ESP32 Display Controller and Graphics Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('_v_g_a_2_network_terminal_2_network_terminal_8ino-example.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">VGA/NetworkTerminal/NetworkTerminal.ino</div>  </div>
</div><!--header-->
<div class="contents">
<p>Network VT/ANSI Terminal</p>
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">  Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - &lt;http://www.fabgl.com&gt;</span></div><div class="line"><span class="comment">  Copyright (c) 2019-2021 Fabrizio Di Vittorio.</span></div><div class="line"><span class="comment">  All rights reserved.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">* Please contact fdivitto2013@gmail.com if you need a commercial license.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">* This library and related software is available under GPL v3.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  FabGL is free software: you can redistribute it and/or modify</span></div><div class="line"><span class="comment">  it under the terms of the GNU General Public License as published by</span></div><div class="line"><span class="comment">  the Free Software Foundation, either version 3 of the License, or</span></div><div class="line"><span class="comment">  (at your option) any later version.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  FabGL is distributed in the hope that it will be useful,</span></div><div class="line"><span class="comment">  but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div><div class="line"><span class="comment">  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span></div><div class="line"><span class="comment">  GNU General Public License for more details.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  You should have received a copy of the GNU General Public License</span></div><div class="line"><span class="comment">  along with FabGL.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="fabgl_8h.html">fabgl.h</a>&quot;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;WiFi.h&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="_i_c_m_p_8h.html">network/ICMP.h</a>&quot;</span></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">char</span> <span class="keyword">const</span> * AUTOEXEC = <span class="stringliteral">&quot;info\r&quot;</span></div><div class="line">                        <span class="stringliteral">&quot;keyb us\r&quot;</span></div><div class="line">                        <span class="stringliteral">&quot;scan\r&quot;</span>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">enum class</span> State { Prompt,</div><div class="line">                   PromptInput,</div><div class="line">                   UnknownCommand,</div><div class="line">                   Help,</div><div class="line">                   <a class="code" href="group___enumerations_gaae85628862e3db5a13e7c21a90589c1d.html#ggaae85628862e3db5a13e7c21a90589c1da4059b0251f66a18cb56f544728796875">Info</a>,</div><div class="line">                   Wifi,</div><div class="line">                   TelnetInit,</div><div class="line">                   Telnet,</div><div class="line">                   Scan,</div><div class="line">                   Ping,</div><div class="line">                   Reset,</div><div class="line">                   Keyb</div><div class="line">                 };</div><div class="line"></div><div class="line"></div><div class="line">State        state = State::Prompt;</div><div class="line">WiFiClient   client;</div><div class="line"><span class="keywordtype">char</span> <span class="keyword">const</span> * currentScript = <span class="keyword">nullptr</span>;</div><div class="line"><span class="keywordtype">bool</span>         error = <span class="keyword">false</span>;</div><div class="line"></div><div class="line"></div><div class="line"><a name="_a0"></a><a class="code" href="classfabgl_1_1_v_g_a_text_controller.html">fabgl::VGATextController</a> DisplayController;</div><div class="line"><a name="_a1"></a><a class="code" href="classfabgl_1_1_p_s2_controller.html">fabgl::PS2Controller</a>     PS2Controller;</div><div class="line"><a name="_a2"></a><a class="code" href="classfabgl_1_1_terminal.html">fabgl::Terminal</a>          Terminal;</div><div class="line"><a name="_a3"></a><a class="code" href="classfabgl_1_1_line_editor.html">fabgl::LineEditor</a>        LineEditor(&amp;Terminal);</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> exe_info()</div><div class="line">{</div><div class="line">  Terminal.<a name="a4"></a><a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m* * FabGL - Network VT/ANSI Terminal\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[94m* * 2019-2021 by Fabrizio Di Vittorio - www.fabgl.com\e[92m\r\n\n&quot;</span>);</div><div class="line">  Terminal.printf(<span class="stringliteral">&quot;\e[92mScreen Size        :\e[93m %d x %d\r\n&quot;</span>, DisplayController.<a name="a5"></a><a class="code" href="classfabgl_1_1_base_display_controller_a749df909b39fd096bf6e2813f2f5324c.html#a749df909b39fd096bf6e2813f2f5324c">getScreenWidth</a>(), DisplayController.<a name="a6"></a><a class="code" href="classfabgl_1_1_base_display_controller_a0872427e4a351bb3590e8d00096e9cba.html#a0872427e4a351bb3590e8d00096e9cba">getScreenHeight</a>());</div><div class="line">  Terminal.printf(<span class="stringliteral">&quot;\e[92mTerminal Size      :\e[93m %d x %d\r\n&quot;</span>, Terminal.<a name="a7"></a><a class="code" href="classfabgl_1_1_terminal_a6e9094a53fd8a44ad7a061abae461e5c.html#a6e9094a53fd8a44ad7a061abae461e5c">getColumns</a>(), Terminal.<a name="a8"></a><a class="code" href="classfabgl_1_1_terminal_a1bb8ac2a73a5d9e6256505e1bf51c6a9.html#a1bb8ac2a73a5d9e6256505e1bf51c6a9">getRows</a>());</div><div class="line">  Terminal.printf(<span class="stringliteral">&quot;\e[92mFree DMA Memory    :\e[93m %d\r\n&quot;</span>, heap_caps_get_free_size(MALLOC_CAP_DMA));</div><div class="line">  Terminal.printf(<span class="stringliteral">&quot;\e[92mFree 32 bit Memory :\e[93m %d\r\n&quot;</span>, heap_caps_get_free_size(MALLOC_CAP_32BIT));</div><div class="line">  <span class="keywordflow">if</span> (WiFi.status() == WL_CONNECTED) {</div><div class="line">    Terminal.printf(<span class="stringliteral">&quot;\e[92mWiFi SSID          :\e[93m %s\r\n&quot;</span>, WiFi.SSID().c_str());</div><div class="line">    Terminal.printf(<span class="stringliteral">&quot;\e[92mCurrent IP         :\e[93m %s\r\n&quot;</span>, WiFi.localIP().toString().c_str());</div><div class="line">  }</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\n\e[92mType \e[93mhelp\e[92m to print all available commands.\r\n&quot;</span>);</div><div class="line">  error = <span class="keyword">false</span>;</div><div class="line">  state = State::Prompt;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> exe_help()</div><div class="line">{</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[93mhelp\e[92m\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m  Shows this help.\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[93minfo\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m  Shows system info.\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[93mscan\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m  Scan for WiFi networks.\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[93mwifi [SSID PASSWORD]\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m  Connect to SSID using PASSWORD.\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m  Example:\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m    wifi MyWifi MyPassword\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[93mtelnet HOST [PORT]\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m  Open telnet session with HOST (IP or host name) using PORT.\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m  Example:\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m    telnet towel.blinkenlights.nl\e[92m\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[93mping HOST\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m  Ping a HOST (IP or host name).\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m  Example:\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m    ping 8.8.8.8\e[92m\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[93mreboot\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m  Restart the system.\e[92m\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[93mkeyb LAYOUT\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m  Set keyboard layout. LAYOUT can be &#39;us&#39;, &#39;uk&#39;, &#39;de&#39;, &#39;it&#39;, &#39;es&#39;, &#39;fr&#39;, &#39;be&#39;\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m  Example:\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m    keyb de\e[92m\r\n&quot;</span>);</div><div class="line">  error = <span class="keyword">false</span>;</div><div class="line">  state = State::Prompt;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> decode_command()</div><div class="line">{</div><div class="line">  <span class="keyword">auto</span> inputLine = LineEditor.get();</div><div class="line">  <span class="keywordflow">if</span> (*inputLine == 0)</div><div class="line">    state = State::Prompt;</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp(inputLine, <span class="stringliteral">&quot;help&quot;</span>, 4) == 0)</div><div class="line">    state = State::Help;</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp(inputLine, <span class="stringliteral">&quot;info&quot;</span>, 4) == 0)</div><div class="line">    state = State::Info;</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp(inputLine, <span class="stringliteral">&quot;wifi&quot;</span>, 4) == 0)</div><div class="line">    state = State::Wifi;</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp(inputLine, <span class="stringliteral">&quot;telnet&quot;</span>, 6) == 0)</div><div class="line">    state = State::TelnetInit;</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp(inputLine, <span class="stringliteral">&quot;scan&quot;</span>, 4) == 0)</div><div class="line">    state = State::Scan;</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp(inputLine, <span class="stringliteral">&quot;ping&quot;</span>, 4) == 0)</div><div class="line">    state = State::Ping;</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp(inputLine, <span class="stringliteral">&quot;reboot&quot;</span>, 6) == 0)</div><div class="line">    state = State::Reset;</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp(inputLine, <span class="stringliteral">&quot;keyb&quot;</span>, 4) == 0)</div><div class="line">    state = State::Keyb;</div><div class="line">  <span class="keywordflow">else</span></div><div class="line">    state = State::UnknownCommand;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> exe_prompt()</div><div class="line">{</div><div class="line">  <span class="keywordflow">if</span> (currentScript) {</div><div class="line">    <span class="comment">// process commands from script</span></div><div class="line">    <span class="keywordflow">if</span> (*currentScript == 0 || error) {</div><div class="line">      <span class="comment">// end of script, return to prompt</span></div><div class="line">      currentScript = <span class="keyword">nullptr</span>;</div><div class="line">      state = State::Prompt;</div><div class="line">    } <span class="keywordflow">else</span> {</div><div class="line">      <span class="comment">// execute current line and move to the next one</span></div><div class="line">      <span class="keywordtype">int</span> linelen = strchr(currentScript, <span class="charliteral">&#39;\r&#39;</span>) - currentScript;</div><div class="line">      LineEditor.setText(currentScript, linelen);</div><div class="line">      currentScript += linelen + 1;</div><div class="line">      decode_command();</div><div class="line">    }</div><div class="line">  } <span class="keywordflow">else</span> {</div><div class="line">    <span class="comment">// process commands from keyboard</span></div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;&gt;&quot;</span>);</div><div class="line">    state = State::PromptInput;</div><div class="line">  }</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> exe_promptInput()</div><div class="line">{</div><div class="line">  LineEditor.setText(<span class="stringliteral">&quot;&quot;</span>);</div><div class="line">  LineEditor.edit();</div><div class="line">  decode_command();</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> exe_scan()</div><div class="line">{</div><div class="line">  <span class="keyword">static</span> <span class="keywordtype">char</span> <span class="keyword">const</span> * ENC2STR[] = { <span class="stringliteral">&quot;Open&quot;</span>, <span class="stringliteral">&quot;WEP&quot;</span>, <span class="stringliteral">&quot;WPA-PSK&quot;</span>, <span class="stringliteral">&quot;WPA2-PSK&quot;</span>, <span class="stringliteral">&quot;WPA/WPA2-PSK&quot;</span>, <span class="stringliteral">&quot;WPA-ENTERPRISE&quot;</span> };</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;Scanning...&quot;</span>);</div><div class="line">  Terminal.<a name="a9"></a><a class="code" href="classfabgl_1_1_terminal_af04a513134593e61c4575b266c8bf0ee.html#af04a513134593e61c4575b266c8bf0ee">flush</a>();</div><div class="line">  <span class="keywordtype">int</span> networksCount = WiFi.scanNetworks();</div><div class="line">  Terminal.printf(<span class="stringliteral">&quot;%d network(s) found\r\n&quot;</span>, networksCount);</div><div class="line">  <span class="keywordflow">if</span> (networksCount) {</div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>   (<span class="stringliteral">&quot;\e[90m #\e[4GSSID\e[45GRSSI\e[55GCh\e[60GEncryption\e[92m\r\n&quot;</span>);</div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; networksCount; ++i)</div><div class="line">      Terminal.printf(<span class="stringliteral">&quot;\e[93m %d\e[4G%s\e[93m\e[45G%d dBm\e[55G%d\e[60G%s\e[92m\r\n&quot;</span>, i + 1, WiFi.SSID(i).c_str(), WiFi.RSSI(i), WiFi.channel(i), ENC2STR[WiFi.encryptionType(i)]);</div><div class="line">  }</div><div class="line">  WiFi.scanDelete();</div><div class="line">  error = <span class="keyword">false</span>;</div><div class="line">  state = State::Prompt;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> exe_wifi()</div><div class="line">{</div><div class="line">  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> MAX_SSID_SIZE = 32;</div><div class="line">  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> MAX_PSW_SIZE  = 32;</div><div class="line">  <span class="keywordtype">char</span> ssid[MAX_SSID_SIZE + 1];</div><div class="line">  <span class="keywordtype">char</span> psw[MAX_PSW_SIZE + 1] = {0};</div><div class="line">  error = <span class="keyword">true</span>;</div><div class="line">  <span class="keyword">auto</span> inputLine = LineEditor.get();</div><div class="line">  <span class="keywordflow">if</span> (sscanf(inputLine, <span class="stringliteral">&quot;wifi %32s %32s&quot;</span>, ssid, psw) &gt;= 1) {</div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;Connecting WiFi...&quot;</span>);</div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_af04a513134593e61c4575b266c8bf0ee.html#af04a513134593e61c4575b266c8bf0ee">flush</a>();</div><div class="line">    WiFi.disconnect(<span class="keyword">true</span>, <span class="keyword">true</span>);</div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 2; ++i) {</div><div class="line">      WiFi.begin(ssid, psw);</div><div class="line">      <span class="keywordflow">if</span> (WiFi.waitForConnectResult() == WL_CONNECTED)</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      WiFi.disconnect(<span class="keyword">true</span>, <span class="keyword">true</span>);</div><div class="line">    }</div><div class="line">    <span class="keywordflow">if</span> (WiFi.status() == WL_CONNECTED) {</div><div class="line">      Terminal.printf(<span class="stringliteral">&quot;connected to %s, IP is %s\r\n&quot;</span>, WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());</div><div class="line">      error = <span class="keyword">false</span>;</div><div class="line">    } <span class="keywordflow">else</span> {</div><div class="line">      Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;failed!\r\n&quot;</span>);</div><div class="line">    }</div><div class="line">  }</div><div class="line">  state = State::Prompt;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> exe_telnetInit()</div><div class="line">{</div><div class="line">  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> MAX_HOST_SIZE = 32;</div><div class="line">  <span class="keywordtype">char</span> host[MAX_HOST_SIZE + 1];</div><div class="line">  <span class="keywordtype">int</span> port;</div><div class="line">  error = <span class="keyword">true</span>;</div><div class="line">  <span class="keyword">auto</span> inputLine = LineEditor.get();</div><div class="line">  <span class="keywordtype">int</span> pCount = sscanf(inputLine, <span class="stringliteral">&quot;telnet %32s %d&quot;</span>, host, &amp;port);</div><div class="line">  <span class="keywordflow">if</span> (pCount &gt; 0) {</div><div class="line">    <span class="keywordflow">if</span> (pCount == 1)</div><div class="line">      port = 23;</div><div class="line">    Terminal.printf(<span class="stringliteral">&quot;Trying %s...\r\n&quot;</span>, host);</div><div class="line">    <span class="keywordflow">if</span> (client.connect(host, port)) {</div><div class="line">      Terminal.printf(<span class="stringliteral">&quot;Connected to %s\r\n&quot;</span>, host);</div><div class="line">      error = <span class="keyword">false</span>;</div><div class="line">      state = State::Telnet;</div><div class="line">    } <span class="keywordflow">else</span> {</div><div class="line">      Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;Unable to connect to remote host\r\n&quot;</span>);</div><div class="line">      state = State::Prompt;</div><div class="line">    }</div><div class="line">  } <span class="keywordflow">else</span> {</div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;Mistake\r\n&quot;</span>);</div><div class="line">    state = State::Prompt;</div><div class="line">  }</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> clientWaitForChar()</div><div class="line">{</div><div class="line">  <span class="comment">// not so good...:-)</span></div><div class="line">  <span class="keywordflow">while</span> (!client.available())</div><div class="line">    ;</div><div class="line">  <span class="keywordflow">return</span> client.read();</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> exe_telnet()</div><div class="line">{</div><div class="line">  <span class="comment">// process data from remote host (up to 1024 codes at the time)</span></div><div class="line">  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; client.available() &amp;&amp; i &lt; 1024; ++i) {</div><div class="line">    <span class="keywordtype">int</span> c = client.read();</div><div class="line">    <span class="keywordflow">if</span> (c == 0xFF) {</div><div class="line">      <span class="comment">// IAC (Interpret As Command)</span></div><div class="line">      uint8_t cmd = clientWaitForChar();</div><div class="line">      uint8_t opt = clientWaitForChar();</div><div class="line">      <span class="keywordflow">if</span> (cmd == 0xFD &amp;&amp; opt == 0x1F) {</div><div class="line">        <span class="comment">// DO WINDOWSIZE</span></div><div class="line">        client.write(<span class="stringliteral">&quot;\xFF\xFB\x1F&quot;</span>, 3); <span class="comment">// IAC WILL WINDOWSIZE</span></div><div class="line">        client.write(<span class="stringliteral">&quot;\xFF\xFA\x1F&quot;</span> <span class="stringliteral">&quot;\x00\x50\x00\x19&quot;</span> <span class="stringliteral">&quot;\xFF\xF0&quot;</span>, 9);  <span class="comment">// IAC SB WINDOWSIZE 0 80 0 25 IAC SE</span></div><div class="line">      } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (cmd == 0xFD &amp;&amp; opt == 0x18) {</div><div class="line">        <span class="comment">// DO TERMINALTYPE</span></div><div class="line">        client.write(<span class="stringliteral">&quot;\xFF\xFB\x18&quot;</span>, 3); <span class="comment">// IAC WILL TERMINALTYPE</span></div><div class="line">      } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (cmd == 0xFA &amp;&amp; opt == 0x18) {</div><div class="line">        <span class="comment">// SB TERMINALTYPE</span></div><div class="line">        c = clientWaitForChar();  <span class="comment">// bypass &#39;1&#39;</span></div><div class="line">        c = clientWaitForChar();  <span class="comment">// bypass IAC</span></div><div class="line">        c = clientWaitForChar();  <span class="comment">// bypass SE</span></div><div class="line">        client.write(<span class="stringliteral">&quot;\xFF\xFA\x18\x00&quot;</span> <span class="stringliteral">&quot;wsvt25&quot;</span> <span class="stringliteral">&quot;\xFF\xF0&quot;</span>, 12); <span class="comment">// IAC SB TERMINALTYPE 0 &quot;....&quot; IAC SE</span></div><div class="line">      } <span class="keywordflow">else</span> {</div><div class="line">        uint8_t pck[3] = {0xFF, 0, opt};</div><div class="line">        <span class="keywordflow">if</span> (cmd == 0xFD)  <span class="comment">// DO -&gt; WONT</span></div><div class="line">          pck[1] = 0xFC;</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (cmd == 0xFB) <span class="comment">// WILL -&gt; DO</span></div><div class="line">          pck[1] = 0xFD;</div><div class="line">        client.write(pck, 3);</div><div class="line">      }</div><div class="line">    } <span class="keywordflow">else</span> {</div><div class="line">      Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(c);</div><div class="line">    }</div><div class="line">  }</div><div class="line">  <span class="comment">// process data from terminal (keyboard)</span></div><div class="line">  <span class="keywordflow">while</span> (Terminal.<a name="a10"></a><a class="code" href="classfabgl_1_1_terminal_a4549a76725f2e4c013e4d57018366109.html#a4549a76725f2e4c013e4d57018366109">available</a>()) {</div><div class="line">    client.write( Terminal.<a name="a11"></a><a class="code" href="classfabgl_1_1_terminal_aaab5dab5b969a87f538242e524431637.html#aaab5dab5b969a87f538242e524431637">read</a>() );</div><div class="line">  }</div><div class="line">  <span class="comment">// return to prompt?</span></div><div class="line">  <span class="keywordflow">if</span> (!client.connected()) {</div><div class="line">    client.stop();</div><div class="line">    state = State::Prompt;</div><div class="line">  }</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> exe_ping()</div><div class="line">{</div><div class="line">  <span class="keywordtype">char</span> host[64];</div><div class="line">  <span class="keyword">auto</span> inputLine = LineEditor.get();</div><div class="line">  <span class="keywordtype">int</span> pcount = sscanf(inputLine, <span class="stringliteral">&quot;ping %s&quot;</span>, host);</div><div class="line">  <span class="keywordflow">if</span> (pcount &gt; 0) {</div><div class="line">    <span class="keywordtype">int</span> sent = 0, recv = 0;</div><div class="line">    <a name="_a12"></a><a class="code" href="classfabgl_1_1_i_c_m_p.html">fabgl::ICMP</a> icmp;</div><div class="line">    <span class="keywordflow">while</span> (<span class="keyword">true</span>) {</div><div class="line"></div><div class="line">      <span class="comment">// CTRL-C ?</span></div><div class="line">      <span class="keywordflow">if</span> (Terminal.<a class="code" href="classfabgl_1_1_terminal_a4549a76725f2e4c013e4d57018366109.html#a4549a76725f2e4c013e4d57018366109">available</a>() &amp;&amp; Terminal.<a class="code" href="classfabgl_1_1_terminal_aaab5dab5b969a87f538242e524431637.html#aaab5dab5b969a87f538242e524431637">read</a>() == 0x03)</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">      <span class="keywordtype">int</span> t = icmp.<a name="a13"></a>ping(host);</div><div class="line">      <span class="keywordflow">if</span> (t &gt;= 0) {</div><div class="line">        Terminal.printf(<span class="stringliteral">&quot;%d bytes from %s: icmp_seq=%d ttl=%d time=%.3f ms\r\n&quot;</span>, icmp.<a name="a14"></a>receivedBytes(), icmp.<a name="a15"></a>hostIP().toString().c_str(), icmp.<a name="a16"></a>receivedSeq(), icmp.<a name="a17"></a>receivedTTL(), (double)t/1000.0);</div><div class="line">        delay(1000);</div><div class="line">        ++recv;</div><div class="line">      } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (t == -2) {</div><div class="line">        Terminal.printf(<span class="stringliteral">&quot;Cannot resolve %s: Unknown host\r\n&quot;</span>, host);</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      } <span class="keywordflow">else</span> {</div><div class="line">        Terminal.printf(<span class="stringliteral">&quot;Request timeout for icmp_seq %d\r\n&quot;</span>, icmp.receivedSeq());</div><div class="line">      }</div><div class="line">      ++sent;</div><div class="line"></div><div class="line">    }</div><div class="line">    <span class="keywordflow">if</span> (sent &gt; 0) {</div><div class="line">      Terminal.printf(<span class="stringliteral">&quot;--- %s ping statistics ---\r\n&quot;</span>, host);</div><div class="line">      Terminal.printf(<span class="stringliteral">&quot;%d packets transmitted, %d packets received, %.1f%% packet loss\r\n&quot;</span>, sent, recv, (<span class="keywordtype">double</span>)(sent - recv) / sent * 100.0);</div><div class="line">    }</div><div class="line">  }</div><div class="line">  state = State::Prompt;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> exe_keyb()</div><div class="line">{</div><div class="line">  <span class="keywordflow">if</span> (PS2Controller.<a name="a18"></a><a class="code" href="classfabgl_1_1_p_s2_controller_add3a17b29e9908b6e5cca6f52122119b.html#add3a17b29e9908b6e5cca6f52122119b">keyboard</a>()-&gt;<a name="a19"></a><a class="code" href="classfabgl_1_1_keyboard_aef1dd1399d92a09d1ed115911b563688.html#aef1dd1399d92a09d1ed115911b563688">isKeyboardAvailable</a>()) {</div><div class="line">    <span class="keywordtype">char</span> layout[3];</div><div class="line">    <span class="keyword">auto</span> inputLine = LineEditor.get();</div><div class="line">    <span class="keywordflow">if</span> (sscanf(inputLine, <span class="stringliteral">&quot;keyb %2s&quot;</span>, layout) == 1) {</div><div class="line">      <span class="keywordflow">if</span> (strcasecmp(layout, <span class="stringliteral">&quot;US&quot;</span>) == 0)</div><div class="line">        Terminal.<a name="a20"></a><a class="code" href="classfabgl_1_1_terminal_ab7bbbedef758e471e6eb693acfb17c33.html#ab7bbbedef758e471e6eb693acfb17c33">keyboard</a>()-&gt;<a name="a21"></a><a class="code" href="classfabgl_1_1_keyboard_aca97a7179d5358ec795485e15618b243.html#aca97a7179d5358ec795485e15618b243">setLayout</a>(&amp;fabgl::USLayout);</div><div class="line">      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcasecmp(layout, <span class="stringliteral">&quot;UK&quot;</span>) == 0)</div><div class="line">        Terminal.<a class="code" href="classfabgl_1_1_terminal_ab7bbbedef758e471e6eb693acfb17c33.html#ab7bbbedef758e471e6eb693acfb17c33">keyboard</a>()-&gt;<a class="code" href="classfabgl_1_1_keyboard_aca97a7179d5358ec795485e15618b243.html#aca97a7179d5358ec795485e15618b243">setLayout</a>(&amp;fabgl::UKLayout);</div><div class="line">      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcasecmp(layout, <span class="stringliteral">&quot;DE&quot;</span>) == 0)</div><div class="line">        Terminal.<a class="code" href="classfabgl_1_1_terminal_ab7bbbedef758e471e6eb693acfb17c33.html#ab7bbbedef758e471e6eb693acfb17c33">keyboard</a>()-&gt;<a class="code" href="classfabgl_1_1_keyboard_aca97a7179d5358ec795485e15618b243.html#aca97a7179d5358ec795485e15618b243">setLayout</a>(&amp;fabgl::GermanLayout);</div><div class="line">      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcasecmp(layout, <span class="stringliteral">&quot;IT&quot;</span>) == 0)</div><div class="line">        Terminal.<a class="code" href="classfabgl_1_1_terminal_ab7bbbedef758e471e6eb693acfb17c33.html#ab7bbbedef758e471e6eb693acfb17c33">keyboard</a>()-&gt;<a class="code" href="classfabgl_1_1_keyboard_aca97a7179d5358ec795485e15618b243.html#aca97a7179d5358ec795485e15618b243">setLayout</a>(&amp;fabgl::ItalianLayout);</div><div class="line">      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcasecmp(layout, <span class="stringliteral">&quot;ES&quot;</span>) == 0)</div><div class="line">        Terminal.<a class="code" href="classfabgl_1_1_terminal_ab7bbbedef758e471e6eb693acfb17c33.html#ab7bbbedef758e471e6eb693acfb17c33">keyboard</a>()-&gt;<a class="code" href="classfabgl_1_1_keyboard_aca97a7179d5358ec795485e15618b243.html#aca97a7179d5358ec795485e15618b243">setLayout</a>(&amp;fabgl::SpanishLayout);</div><div class="line">      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcasecmp(layout, <span class="stringliteral">&quot;FR&quot;</span>) == 0)</div><div class="line">        Terminal.<a class="code" href="classfabgl_1_1_terminal_ab7bbbedef758e471e6eb693acfb17c33.html#ab7bbbedef758e471e6eb693acfb17c33">keyboard</a>()-&gt;<a class="code" href="classfabgl_1_1_keyboard_aca97a7179d5358ec795485e15618b243.html#aca97a7179d5358ec795485e15618b243">setLayout</a>(&amp;fabgl::FrenchLayout);</div><div class="line">      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcasecmp(layout, <span class="stringliteral">&quot;BE&quot;</span>) == 0)</div><div class="line">        Terminal.<a class="code" href="classfabgl_1_1_terminal_ab7bbbedef758e471e6eb693acfb17c33.html#ab7bbbedef758e471e6eb693acfb17c33">keyboard</a>()-&gt;<a class="code" href="classfabgl_1_1_keyboard_aca97a7179d5358ec795485e15618b243.html#aca97a7179d5358ec795485e15618b243">setLayout</a>(&amp;fabgl::BelgianLayout);</div><div class="line">      <span class="keywordflow">else</span> {</div><div class="line">        Terminal.printf(<span class="stringliteral">&quot;Error! Invalid keyboard layout.\r\n&quot;</span>);</div><div class="line">        state = State::Prompt;</div><div class="line">        <span class="keywordflow">return</span>;</div><div class="line">      }</div><div class="line">    }</div><div class="line">    Terminal.printf(<span class="stringliteral">&quot;\r\nKeyboard layout is : \e[93m%s\e[92m\r\n\r\n&quot;</span>, Terminal.<a class="code" href="classfabgl_1_1_terminal_ab7bbbedef758e471e6eb693acfb17c33.html#ab7bbbedef758e471e6eb693acfb17c33">keyboard</a>()-&gt;<a name="a22"></a><a class="code" href="classfabgl_1_1_keyboard_a164361d7dc1597cd75db35c06d87e7d6.html#a164361d7dc1597cd75db35c06d87e7d6">getLayout</a>()-&gt;<a name="a23"></a><a class="code" href="structfabgl_1_1_keyboard_layout_a710bce51374aba96ab04912897666c35.html#a710bce51374aba96ab04912897666c35">desc</a>);</div><div class="line">  } <span class="keywordflow">else</span> {</div><div class="line">    Terminal.printf(<span class="stringliteral">&quot;No keyboard present\r\n&quot;</span>);</div><div class="line">  }</div><div class="line">  state = State::Prompt;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> setup()</div><div class="line">{</div><div class="line">  <span class="comment">//Serial.begin(115200); // DEBUG ONLY</span></div><div class="line"></div><div class="line">  PS2Controller.<a name="a24"></a><a class="code" href="classfabgl_1_1_p_s2_controller_ab8520612804a921ad834b41214a99c09.html#ab8520612804a921ad834b41214a99c09">begin</a>(PS2Preset::KeyboardPort0);</div><div class="line"></div><div class="line">  DisplayController.<a name="a25"></a><a class="code" href="classfabgl_1_1_v_g_a_text_controller_a406a206bc0e13ee2a48591fcfdae6e22.html#a406a206bc0e13ee2a48591fcfdae6e22">begin</a>();</div><div class="line">  DisplayController.<a name="a26"></a><a class="code" href="classfabgl_1_1_v_g_a_text_controller_a4583a73c34544a3ab09802f045c16664.html#a4583a73c34544a3ab09802f045c16664">setResolution</a>();</div><div class="line"></div><div class="line">  Terminal.<a name="a27"></a><a class="code" href="classfabgl_1_1_terminal_aebaecc1fa474fddc48dd5778024b19a5.html#aebaecc1fa474fddc48dd5778024b19a5">begin</a>(&amp;DisplayController);</div><div class="line">  Terminal.<a name="a28"></a><a class="code" href="classfabgl_1_1_terminal_a068123b964647130439aa949370181dc.html#a068123b964647130439aa949370181dc">connectLocally</a>();      <span class="comment">// to use Terminal.read(), available(), etc..</span></div><div class="line">  <span class="comment">//Terminal.setLogStream(Serial);  // DEBUG ONLY</span></div><div class="line"></div><div class="line">  Terminal.<a name="a29"></a><a class="code" href="classfabgl_1_1_terminal_ae6f04360ccc33a519bdff509fd81df62.html#ae6f04360ccc33a519bdff509fd81df62">setBackgroundColor</a>(<a name="a30"></a><a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1cac1e9bce8242f443c54c7405223d616cd">Color::Black</a>);</div><div class="line">  Terminal.<a name="a31"></a><a class="code" href="classfabgl_1_1_terminal_afad23f091c4bb07a71963f5f7aa1831d.html#afad23f091c4bb07a71963f5f7aa1831d">setForegroundColor</a>(<a name="a32"></a><a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1ca8e551a5ca49dca47dd8d5af7a04dd9ea">Color::BrightGreen</a>);</div><div class="line">  Terminal.<a name="a33"></a><a class="code" href="classfabgl_1_1_terminal_a2da678d7453efcfed190b99ac93a53d0.html#a2da678d7453efcfed190b99ac93a53d0">clear</a>();</div><div class="line"></div><div class="line">  Terminal.<a name="a34"></a><a class="code" href="classfabgl_1_1_terminal_aace245bfe6cab7b4339bd691077e1c23.html#aace245bfe6cab7b4339bd691077e1c23">enableCursor</a>(<span class="keyword">true</span>);</div><div class="line"></div><div class="line">  currentScript = AUTOEXEC;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> loop()</div><div class="line">{</div><div class="line">  <span class="keywordflow">switch</span> (state) {</div><div class="line"></div><div class="line">    <span class="keywordflow">case</span> State::Prompt:</div><div class="line">      exe_prompt();</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">    <span class="keywordflow">case</span> State::PromptInput:</div><div class="line">      exe_promptInput();</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">    <span class="keywordflow">case</span> State::Help:</div><div class="line">      exe_help();</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">    <span class="keywordflow">case</span> State::Info:</div><div class="line">      exe_info();</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">    <span class="keywordflow">case</span> State::Wifi:</div><div class="line">      exe_wifi();</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">    <span class="keywordflow">case</span> State::TelnetInit:</div><div class="line">      exe_telnetInit();</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">    <span class="keywordflow">case</span> State::Telnet:</div><div class="line">      exe_telnet();</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">    <span class="keywordflow">case</span> State::Scan:</div><div class="line">      exe_scan();</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">    <span class="keywordflow">case</span> State::Ping:</div><div class="line">      exe_ping();</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">    <span class="keywordflow">case</span> State::Reset:</div><div class="line">      ESP.restart();</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">    <span class="keywordflow">case</span> State::Keyb:</div><div class="line">      exe_keyb();</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">    <span class="keywordflow">case</span> State::UnknownCommand:</div><div class="line">      Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\r\nMistake\r\n&quot;</span>);</div><div class="line">      state = State::Prompt;</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">    <span class="keywordflow">default</span>:</div><div class="line">      Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\r\nNot Implemeted\r\n&quot;</span>);</div><div class="line">      state = State::Prompt;</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">  }</div><div class="line">}</div><div class="line"></div></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Mon Aug 2 2021 07:08:02 for FabGL by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>
